home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / patch12.zip / COMMON.H next >
C/C++ Source or Header  |  1990-05-30  |  4KB  |  160 lines

  1. /* $Header: common.h,v 2.0.1.2 88/06/22 20:44:53 lwall Locked $
  2.  *
  3.  * $Log:    common.h,v $
  4.  * Revision 2.0.1.2  88/06/22  20:44:53  lwall
  5.  * patch12: sprintf was declared wrong
  6.  * 
  7.  * Revision 2.0.1.1  88/06/03  15:01:56  lwall
  8.  * patch10: support for shorter extensions.
  9.  * 
  10.  * Revision 2.0  86/09/17  15:36:39  lwall
  11.  * Baseline for netwide release.
  12.  * 
  13.  */
  14.  
  15. #define DEBUGGING
  16.  
  17. #define VOIDUSED 7
  18. #include "config.h"
  19.  
  20. /* shut lint up about the following when return value ignored */
  21.  
  22. #define Signal (void)signal
  23. #define Unlink (void)unlink
  24. #define Lseek (void)lseek
  25. #define Fseek (void)fseek
  26. #define Fstat (void)fstat
  27. #define Pclose (void)pclose
  28. #define Close (void)close
  29. #define Fclose (void)fclose
  30. #define Fflush (void)fflush
  31. #define Sprintf (void)sprintf
  32. #define Mktemp (void)mktemp
  33. #define Strcpy (void)strcpy
  34. #define Strcat (void)strcat
  35.  
  36. #include <stdio.h>
  37. #include <assert.h>
  38. #include <sys/types.h>
  39. #include <sys/stat.h>
  40. #include <ctype.h>
  41. #include <signal.h>
  42.  
  43. /* constants */
  44.  
  45. #define TRUE (1)
  46. #define FALSE (0)
  47.  
  48. #define MAXHUNKSIZE 100000        /* is this enough lines? */
  49. #define INITHUNKMAX 125            /* initial dynamic allocation size */
  50. #define MAXLINELEN 1024
  51. #define BUFFERSIZE 1024
  52. #define SCCSPREFIX "s."
  53. #define GET "get -e %s"
  54. #define RCSSUFFIX ",v"
  55. #define CHECKOUT "co -l %s"
  56.  
  57. #ifdef FLEXFILENAMES
  58. #define ORIGEXT ".orig"
  59. #define REJEXT ".rej"
  60. #else
  61. #define ORIGEXT "~"
  62. #define REJEXT "#"
  63. #endif
  64.  
  65. /* handy definitions */
  66.  
  67. #define Null(t) ((t)0)
  68. #define Nullch Null(char *)
  69. #define Nullfp Null(FILE *)
  70. #define Nulline Null(LINENUM)
  71.  
  72. #define Ctl(ch) ((ch) & 037)
  73.  
  74. #define strNE(s1,s2) (strcmp(s1, s2))
  75. #define strEQ(s1,s2) (!strcmp(s1, s2))
  76. #define strnNE(s1,s2,l) (strncmp(s1, s2, l))
  77. #define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
  78.  
  79. /* typedefs */
  80.  
  81. typedef char bool;
  82. typedef long LINENUM;            /* must be signed */
  83. typedef unsigned MEM;            /* what to feed malloc */
  84.  
  85. /* globals */
  86.  
  87. EXT int Argc;                /* guess */
  88. EXT char **Argv;
  89. EXT int Argc_last;            /* for restarting plan_b */
  90. EXT char **Argv_last;
  91.  
  92. EXT struct stat filestat;        /* file statistics area */
  93. EXT int filemode INIT(0644);
  94.  
  95. EXT char buf[MAXLINELEN];        /* general purpose buffer */
  96. EXT FILE *ofp INIT(Nullfp);        /* output file pointer */
  97. EXT FILE *rejfp INIT(Nullfp);        /* reject file pointer */
  98.  
  99. EXT bool using_plan_a INIT(TRUE);    /* try to keep everything in memory */
  100. EXT bool out_of_mem INIT(FALSE);    /* ran out of memory in plan a */
  101.  
  102. #define MAXFILEC 2
  103. EXT int filec INIT(0);            /* how many file arguments? */
  104. EXT char *filearg[MAXFILEC];
  105. EXT bool ok_to_create_file INIT(FALSE);
  106. EXT char *bestguess INIT(Nullch);    /* guess at correct filename */
  107.  
  108. EXT char *outname INIT(Nullch);
  109. EXT char rejname[128];
  110.  
  111. EXT char *origext INIT(Nullch);
  112. EXT char *origprae INIT(Nullch);
  113.  
  114. EXT char TMPOUTNAME[] INIT("/tmp/patchoXXXXXX");
  115. EXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX");    /* might want /usr/tmp here */
  116. EXT char TMPREJNAME[] INIT("/tmp/patchrXXXXXX");
  117. EXT char TMPPATNAME[] INIT("/tmp/patchpXXXXXX");
  118. EXT bool toutkeep INIT(FALSE);
  119. EXT bool trejkeep INIT(FALSE);
  120.  
  121. EXT LINENUM last_offset INIT(0);
  122. #ifdef DEBUGGING
  123. EXT int debug INIT(0);
  124. #endif
  125. EXT LINENUM maxfuzz INIT(2);
  126. EXT bool force INIT(FALSE);
  127. EXT bool verbose INIT(TRUE);
  128. EXT bool reverse INIT(FALSE);
  129. EXT bool noreverse INIT(FALSE);
  130. EXT bool skip_rest_of_patch INIT(FALSE);
  131. EXT int strippath INIT(957);
  132. EXT bool canonicalize INIT(FALSE);
  133.  
  134. #define CONTEXT_DIFF 1
  135. #define NORMAL_DIFF 2
  136. #define ED_DIFF 3
  137. #define NEW_CONTEXT_DIFF 4
  138. EXT int diff_type INIT(0);
  139.  
  140. EXT bool do_defines INIT(FALSE);    /* patch using ifdef, ifndef, etc. */
  141. EXT char if_defined[128];        /* #ifdef xyzzy */
  142. EXT char not_defined[128];        /* #ifndef xyzzy */
  143. EXT char else_defined[] INIT("#else\n");/* #else */
  144. EXT char end_defined[128];        /* #endif xyzzy */
  145.  
  146. EXT char *revision INIT(Nullch);    /* prerequisite revision, if any */
  147.  
  148. char *malloc();
  149. char *realloc();
  150. char *strcpy();
  151. char *strcat();
  152. long atol();
  153. long lseek();
  154. char *mktemp();
  155. #ifdef CHARSPRINTF
  156. char *sprintf();
  157. #else
  158. int sprintf();
  159. #endif
  160.